#include<bits/stdc++.h>
using namespace std;
int T,n,m,d[100005],v[100005],a[100005],c[100005],L,V,k;
int p[100005],q[100005],cnt[100005];
int chu(int x,int y){
    if(x%y==0){
        return x/y;
    } else {
        return x/y+1;
    }
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>T;
    while(T--){
        vector<int> sum[100005],cnt[100005];
        cin>>n>>m>>L>>V;
        int num=0;
        for(int i=1;i<=n;i++){
            cin>>d[i]>>v[i]>>a[i];
        }
        for(int i=1;i<=m;i++){
            cin>>c[i];
        }
        for(int i=1;i<=n;i++){
            if(a[i]==0){
                if(v[i]>V){
                    int x=lower_bound(c+1,c+m+1,d[i])-c-1;
                    if(x<=m)num++;
                }
            } else if(a[i]>0){
                if(v[i]>V){
                    int x=lower_bound(c+1,c+m+1,d[i])-c-1;
                    if(x<=m) num++;

                } else {
                    int x=V*V-v[i]*v[i];
                    int y=2*a[i];
                    int z=lower_bound(c+1,c+m+1,d[i]+x/y+1)-c-1;
                    if(z<=m) num++;
                }
            }
        }
        cout<<num<<" "<<num<<"\n";
    }
    fclose(stdin);
    fclose(stdout);
    return 0;
}
